package com.ohuang.baseapp.view.listContainer;

import ohos.agp.components.AttrSet;
import ohos.agp.components.ComponentContainer;
import ohos.app.Context;

/**
 *
 * 解决之前ListContainer不能滑动到底部问题   目前已修复改问题无需使用该类
 */
public class ListContainerLayout extends ComponentContainer
        implements
        ComponentContainer.ArrangeListener, ComponentContainer.EstimateSizeListener {
    private Context context;

    public ListContainerLayout(Context context) {
        this(context, null);
    }

    public ListContainerLayout(Context context, AttrSet attrSet) {
        super(context, attrSet);
        init(context);
    }

    private void init(Context context) {
        this.context = context;
        setArrangeListener(this);
        setEstimateSizeListener(this);

    }

    @Override
    public boolean onEstimateSize(int i, int i1) {
        int maxi=EstimateSpec.getSize(i);
        int maxi1=EstimateSpec.getSize(i1);

        setEstimatedSize(EstimateSpec.getSizeWithMode(maxi,EstimateSpec.PRECISE)
                ,EstimateSpec.getSizeWithMode(maxi1,EstimateSpec.PRECISE));
        return true;
    }

    @Override
    public boolean onArrange(int i, int i1, int i2, int i3) {

        getComponentAt(0).estimateSize(
                EstimateSpec.getSizeWithMode(i2,EstimateSpec.PRECISE),
                EstimateSpec.getSizeWithMode(i3,EstimateSpec.PRECISE)
        );
        getComponentAt(0).arrange(0,0,i2,i3);
        return true;
    }
}
